package com.atguigu.gulimall.member.web;

import com.alibaba.fastjson.TypeReference;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.member.feign.MemberOrderService;
import com.atguigu.gulimall.member.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

@Controller
public class MemberWebController {

    @Autowired
    MemberOrderService memberOrderService;


    @GetMapping("/memberOrder.html")
    public String orderListPage(@RequestParam(value = "pageNUm",defaultValue = "1") String pageNum,
                                Model model){

        HashMap<String, Object> params = new HashMap<>();
        params.put("page",pageNum);

        R r = memberOrderService.listWithItem(params);
        if (r.getCode() == 0){
            Map data = r.getData(new TypeReference<Map>() {
            });
            model.addAttribute("orders",data);
        }

        return "orderList";
    }
}
